package com.example.nick.bodyapplication

import com.example.nick.bodyapplication.tools.Tools
import org.junit.Test

import org.junit.Assert.*

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }

    @Test
    fun abc() {
        assertEquals(6, Tools.ccc(3, 3))
    }

    @Test()
    fun compare() {
//        val a = "1383"
//        val b = "1384"
//        val ret = a.compareTo(b)
        var ret = getSpeedStr(1545*1024);
        assertEquals("1.5MB/s", ret)
    }

    fun getSpeedStr(speedKb: Int): String? {
        var showSpeed = ""
        if (speedKb >= 0 && speedKb < 1024) {
            showSpeed = speedKb.toString() + "Kb/s"
        } else if (speedKb >= 1024 && speedKb < 1024 * 1024) {
            showSpeed = java.lang.Long.toString((speedKb / 1024).toLong()) + "KB/s"
        } else if (speedKb >= 1024 * 1024 && speedKb < 1024 * 1024 * 1024) {
            showSpeed = String.format("%.2fMB/s", speedKb.toFloat() / (1024 * 1024))
        }
        return showSpeed
    }
}